package com.dove.service.impl;

import com.dove.mapper.UserMapper;
import com.dove.entity.User;
import com.dove.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl2 implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public Boolean save(User user) {
        if (user.getId() == null) {
            return userMapper.insertUser(user) > 0;
        }
        return userMapper.updateUser(user) > 0;
    }

    @Override
    public Boolean update(User user) {
        return userMapper.updateUser(user) > 0;
    }

    @Override
    public Boolean delete(Integer id) {
        return userMapper.deleteUserById(id) > 0;
    }

    @Override
    public User getById(Integer id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public List<User> getAll() {
        return userMapper.selectAll();
    }


}
